package com.example.sunmiv1.adapter;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.sunmiv1.R;
import com.example.sunmiv1.entity.RechargeRecordInfo;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class RechargeRecordAdapter extends BaseAdapter {

    private List<RechargeRecordInfo.DataBean.ListBean> list;
    private ViewHolder viewHolder;

    public RechargeRecordAdapter(List<RechargeRecordInfo.DataBean.ListBean> list) {
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.recharge_record_adapter, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        RechargeRecordInfo.DataBean.ListBean listBean = list.get(position);
        viewHolder.rechargeRecordScene.setText(listBean.getScene_name());
        viewHolder.rechargeRecordTime.setText(listBean.getAdd_time());
        viewHolder.rechargeRecordStore.setText(listBean.getStoretag());
        viewHolder.rechargeRecordVipName.setText(listBean.getName());
        viewHolder.rechargeRecordPhone.setText(listBean.getMobile_phone());
        viewHolder.rechargeRecordRechargeMoney.setText(listBean.getAll_money() + "");
        viewHolder.rechargeRecordGiveMoney.setText(listBean.getGive_money() + "");
        viewHolder.rechargeRecordPayMoney.setText(listBean.getMoney() + "");
        viewHolder.rechargeRecordMode.setText(listBean.getRepay_name());
        return convertView;
    }

    static class ViewHolder {
        @BindView(R.id.rechargeRecord_scene)
        TextView rechargeRecordScene;
        @BindView(R.id.rechargeRecord_time)
        TextView rechargeRecordTime;
        @BindView(R.id.rechargeRecord_store)
        TextView rechargeRecordStore;
        @BindView(R.id.rechargeRecord_vipName)
        TextView rechargeRecordVipName;
        @BindView(R.id.rechargeRecord_phone)
        TextView rechargeRecordPhone;
        @BindView(R.id.rechargeRecord_rechargeMoney)
        TextView rechargeRecordRechargeMoney;
        @BindView(R.id.rechargeRecord_giveMoney)
        TextView rechargeRecordGiveMoney;
        @BindView(R.id.rechargeRecord_payMoney)
        TextView rechargeRecordPayMoney;
        @BindView(R.id.rechargeRecord_mode)
        TextView rechargeRecordMode;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
